home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Celestin Apprentice 7
/
Apprentice-Release7.iso
/
Source Code
/
Pascal
/
Applications
/
TCPExample
/
TCPExample.p
next >
Wrap
Text File
|
1997-07-18
|
2KB
|
93 lines
program TCPExample;
uses
TextUtils,
PreserveA5,
MyInitialization, TCPTypes, MyTransport, MyStripTelnetCodes, MyConnections, MyStartup,
MyGrowZones;
var
quitNow: boolean;
type
TCPExampleObject = object(LineConnectionObject)
procedure LineAvailable (line: str255);
override;
procedure Established;
override;
procedure Destroy;
override;
function Create: OSStatus;
override;
procedure Failed (oe: OSStatus);
override;
end;
procedure TCPExampleObject.Failed (oe: OSStatus);
begin
writeln('Failed with error ', oe);
inherited Failed(oe);
end;
procedure TCPExampleObject.Established;
begin
writeln('Connection Established, send username');
SendLine('peter');
end;
function TCPExampleObject.Create: OSStatus;
begin
writeln('Create');
Create := inherited Create;
end;
procedure TCPExampleObject.Destroy;
begin
writeln('Connection Closed');
inherited Destroy;
end;
procedure TCPExampleObject.LineAvailable (line: str255);
begin
writeln('>', line);
end;
procedure HandleEvents;
var
dummy: boolean;
er: eventRecord;
begin
dummy := WaitNextEvent(everyEvent, er, 15, nil);
if er.what = keyDown then begin
quitNow := true;
end;
IdleStartup;
end;
var
err: OSStatus;
obj: TCPExampleObject;
msg: integer;
begin
Initialization;
InitStartup;
quitNow := false;
StartupPreserveA5;
StartupConnections;
ConfigureTransport(true);
ConfigureGrowZones( 30000 );
err := Startup(msg);
if err = noErr then begin
new(obj);
obj.NewActiveConnection (0, 'sparky:79');
while not quitNow do begin
HandleEvents;
end;
FinishStartup;
end;
end.